package convert

import "github.com/djimenez/iconv-go"

func ConvertStr2GBK(str string) string {
	body, _ := iconv.ConvertString(str, "utf-8", "gb2312")
	return body
}

func ConvertGBK2UTF8(str string) string {
	body, _ := iconv.ConvertString(str, "gb2312", "utf-8")
	return body
}

func Uint16ToBytes(n uint16) []byte {
	return []byte{
		byte(n >> 8),
		byte(n),
	}
}

func BytesToUint16(array []byte) uint16 {
	var data uint16 = 0
	if len(array) == 2 {
		data = uint16(array[0])<<8 | uint16(array[1])
	}
	return data
}
